package com.atguigu.servlet;

import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/servletA")
public class ServletA extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("servletA service");

        // 请求转发
//        RequestDispatcher rd = req.getRequestDispatcher("/servletB");
//        RequestDispatcher rd = req.getRequestDispatcher("login.html");
        // 请求转发可以转发到WEB-INF中的受保护静态资源
        // 响应重定向不可以定向到WEB-INF中的受保护资源
        RequestDispatcher rd = req.getRequestDispatcher("WEB-INF/regist.html");
        rd.forward(req, resp);
    }
}
